package com.spic.business.train.trainSign.controller;

import com.spic.business.common.core.utils.poi.BusinessExcelUtil;
import com.spic.business.train.trainSign.domain.TrainSign;
import com.spic.business.train.trainSign.dto.TrainSignDto;
import com.spic.business.train.trainSign.service.ITrainSignService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 培训签到Controller
 *
 * @author spic
 * @date 2021-10-15
 */
@RestController
@RequestMapping("/train/trainSign")
public class TrainSignController extends BaseController
{
    @Autowired
    private ITrainSignService trainSignService;

    /**
     * 查询培训签到列表
     */
    @PreAuthorize(hasPermi = "business/train:trainSign:list")
    @GetMapping("/list")
    public TableDataInfo list(TrainSignDto trainSigndto)
    {
        startPage();
        List<TrainSign> list = trainSignService.selectTrainSignList(trainSigndto);
        return getDataTable(list);
    }



    /**
     * 获取培训签到详细信息
     */
    @PreAuthorize(hasPermi = "business/train:trainSign:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(trainSignService.selectTrainSignById(id));
    }

    /**
     * 新增培训签到
     */
    @PreAuthorize(hasPermi = "business/train:trainSign:add")
    @Log(title = "培训签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainSign trainSign)
    {
        return toAjax(trainSignService.insertTrainSign(trainSign));
    }

    /**
     * 修改培训签到
     */
    @PreAuthorize(hasPermi = "business/train:trainSign:edit")
    @Log(title = "培训签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainSign trainSign)
    {
        return toAjax(trainSignService.updateTrainSign(trainSign));
    }

    /**
     * 删除培训签到
     */
    @PreAuthorize(hasPermi = "business/train:trainSign:remove")
    @Log(title = "培训签到", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(trainSignService.deleteTrainSignByIds(ids));
    }
}
